package edu.upenn.cis.cis555.webserver;

import java.net.Socket;
import java.util.LinkedList;
import java.util.Vector;

public class WorkQueue
{
	private Vector<WorkerThread> threads;
	private LinkedList<Socket> queue = new LinkedList<Socket>();

	public WorkQueue() {
		threads = new Vector<WorkerThread>(HttpServer.MAXQUEUE);
		for (int i=0; i < HttpServer.MAXQUEUE; i++) {
			WorkerThread aWorker = new WorkerThread();
			aWorker.start();
			threads.add(aWorker);
		}
	}

	public void addConnection(Socket s) {
		synchronized(queue) {
			queue.addLast(s);
			queue.notify();
		}
	}

	public LinkedList<Socket> getQ() {
		return queue;
	}
	
	public Vector<WorkerThread> getT() {
		return threads;
	}
}
